package com.ruoyi.waterPrice.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.business.waterPrice.WiFarmfeeY;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.waterPrice.mapper.WiFarmacctYMapper;
import com.ruoyi.waterPrice.mapper.WiFarmfeeYMapper;
import com.ruoyi.waterPrice.service.IWiFarmfeeYService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 农户水费核算Service业务层处理
 *
 * @author ps
 * @date 2023-02-16
 */
@Service
public class WiFarmfeeYServiceImpl implements IWiFarmfeeYService {
    @Autowired
    private WiFarmfeeYMapper wiFarmfeeYMapper;
    @Autowired
    private WiFarmacctYMapper wiFarmacctYMapper;
    /**
     * 查询农户水费核算
     *
     * @param feeYr 农户水费核算主键
     * @return 农户水费核算
     */
    @Override
    public WiFarmfeeY selectWiFarmfeeYByFeeYrAndFarmCd(String feeYr, String farmCd) {
        WiFarmfeeY wiFarmfeeY = wiFarmfeeYMapper.selectWiFarmfeeYByFeeYrAndFarmCd(feeYr, farmCd);
        if(wiFarmfeeY==null){
            return new WiFarmfeeY();
        }
        String operNm = wiFarmacctYMapper.getOperNm(wiFarmfeeY.getOperId());
        if(StringUtils.isNotBlank(operNm)){
            wiFarmfeeY.setOperId(operNm);
        }
        String farmNm = wiFarmacctYMapper.getFarmNm(wiFarmfeeY.getFarmCd());
        if(StringUtils.isNotBlank(farmNm)){
            wiFarmfeeY.setFarmNm(farmNm);
        }
        return wiFarmfeeY;
    }

    /**
     * 查询农户水费核算列表
     *
     * @param wiFarmfeeY 农户水费核算
     * @return 农户水费核算
     */
    @Override
    public List<WiFarmfeeY> selectWiFarmfeeYList(WiFarmfeeY wiFarmfeeY) {
        return wiFarmfeeYMapper.selectWiFarmfeeYList(wiFarmfeeY);
    }

    /**
     * 新增农户水费核算
     *
     * @param wiFarmfeeY 农户水费核算
     * @return 结果
     */
    @Override
    public int insertWiFarmfeeY(WiFarmfeeY wiFarmfeeY) {
        return wiFarmfeeYMapper.insertWiFarmfeeY(wiFarmfeeY);
    }

    /**
     * 修改农户水费核算
     *
     * @param wiFarmfeeY 农户水费核算
     * @return 结果
     */
    @Override
    public int updateWiFarmfeeY(WiFarmfeeY wiFarmfeeY) {
        return wiFarmfeeYMapper.updateWiFarmfeeY(wiFarmfeeY);
    }

    /**
     * 批量删除农户水费核算
     *
     * @param feeYrs 需要删除的农户水费核算主键
     * @return 结果
     */
    @Override
    public int deleteWiFarmfeeYByFeeYrs(String[] feeYrs) {
        return wiFarmfeeYMapper.deleteWiFarmfeeYByFeeYrs(feeYrs);
    }

    /**
     * 删除农户水费核算信息
     *
     * @param feeYr 农户水费核算主键
     * @return 结果
     */
    @Override
    public int deleteWiFarmfeeYByFeeYrAndFarmCd(String feeYr, String farmCd) {
        return wiFarmfeeYMapper.deleteWiFarmfeeYByFeeYrAndFarmCd(feeYr, farmCd);
    }

}
